package com.jian.show;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author Jiange
 * @create 2021-07-16-12:27
 */

class MyThread implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        return 200;
    }
}

public class CallableShow {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> task = new FutureTask<Integer>(new MyThread());//只会调用一次 得到结果
        new Thread(task).start();
        while(!task.isDone()){
            System.out.println("wait...");
        }
        System.out.println(task.get());
    }
}
